package com.dstz.demo.rest.controller;

import com.alibaba.fastjson.JSON;
import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.GysgGysryxxManager;
import com.dstz.demo.core.manager.MaterialsUploadManager;
import com.dstz.demo.core.model.FindSupplier;
import com.dstz.demo.core.model.GysgGysryxx;
import com.dstz.sys.util.ContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * 供应商人员信息表 ��������<br/>
 * @author  aschs
 * </pre>
 */
@RestController
@RequestMapping("/sys/gysgGysryxx")
public class GysgGysryxxController extends BaseController<GysgGysryxx>{
	@Resource
	GysgGysryxxManager gysgGysryxxManager;


	@Override
	protected String getModelDesc() {
		return "供应商人员信息表";
	}

	@Autowired(required = false)
	MaterialsUploadManager materialsUploadManager;

	//添加调查任务中材料的信息，在材料库中点击提交，
	@RequestMapping("addFindings/{id}/{materialID}")
	public String addFindings(String dcyf, @PathVariable("id") String id, @PathVariable("materialID") String materialID, HttpServletRequest request) {
		String list1 = request.getParameter("list");
		List<FindSupplier> findSuppliers = JSON.parseArray(list1, FindSupplier.class);
		String currentUserId = ContextUtil.getCurrentUserId();
		System.out.println(currentUserId+"我获取到了");
		materialsUploadManager.addFindings(id, materialID, findSuppliers, dcyf,currentUserId);
		return null;
	}

	//添加调查任务中服务的信息，点击提交之后
	@GetMapping("addFindingsService/{id}/{materialID}")
	public String addFindingsService(String dcyf, @PathVariable("id") String id, @PathVariable("materialID") String materialID, HttpServletRequest request) {
		String list1 = request.getParameter("list");
		List<FindSupplier> findSuppliers = JSON.parseArray(list1, FindSupplier.class);
		String currentUserId = ContextUtil.getCurrentUserId();
		System.out.println(currentUserId+"我获取到了");
		materialsUploadManager.addFindingsService(id, materialID, findSuppliers, dcyf,currentUserId);
		return null;
	}

}
